<?php 
$this->load->view('includes/header.php');
?>
<div class="span9">                   
		<ul id="js-news" class="js-hidden">
             <?php foreach($news as $new): ?>
              <li class="news-item"><a href="<?php echo $new->adv_url; ?>" target="_blank"><?php echo $new->descriptions; ?></a></li>
            <?php endforeach ?>
		</ul>
    <div class="main_content">
        <h3 class="title"><span class="pull-left">Featured Ads</span><span class="pull-right"><a href="<?php echo base_url('/classifieds'); ?>">View all listings</a></span></h3>
        <div class="container-fluid">
            <div class="row-fluid product_listing">
			<?php foreach($clist as $ad): ?>
                <div class="span3">
                    <div class="item">
                        <a href="<?php echo base_url('/classifieds') . '/details/'. $ad->advid; ?>">
						<?php
							if (isset($ad->primary_image)){
								$url = '/assets/uploads/classifieds/' . $ad->primary_image;
								}
								else {
									$url = '/assets/uploads/dummy.png';
								}
						?>
						<img class="img" src=<?php echo site_url($url); ?> alt="<?php echo $ad->title; ?>" title="<?php echo $ad->title; ?> height="187" width="187" style='width:187px;height:137px;overflow:hidden;'></a>
                        <a href="<?php echo base_url('/classifieds') . '/details/'. $ad->advid; ?>" class="title"><?php echo $ad->title; ?></a> <span class="label label-success">new</span><br/>in <a href="<?php echo base_url('/classifieds') . '/browse/'. $ad->id; ?>" class="subinfo"><?php echo $ad->cat_descriptions; ?></a> by <a href="#" class="subinfo"><?php echo $ad->contact_person; ?></a>
                        <p><?php 
                        $cleandesc = strip_tags ($ad->description);
                        $desc = (strlen($cleandesc) > 150) ? substr($cleandesc,0,150).'...' : $cleandesc;
                         echo $desc; ?></p>
                    </div>
                </div>
			<?php endforeach; ?>
            </div>
            <hr>
		<div class="row-fluid">
		  <div class="span4">
		  <div class="well-small" style="padding-left: 25px;">
		  <p class="category-title">Buy and Sell</p>
			  <ul id="classifieds">
				<?php foreach($advTypes as $advType): ?>					
							<li><a href="<?php echo base_url('/classifieds/browse/'. $advType->id); ?>"><?php echo $advType->name; ?></a><span>(<?php echo $advType->count; ?>)</span></li>
				<?php endforeach ?>
			  </ul>
		  </div>
		  </div>
		  <div class="span4">  
		  <div class="well-small">
		  <p class="category-title">Property</p>
			  <ul id="classifieds">
				<?php foreach($propTypes as $propType): ?>					
							<li>
								<a href="<?php echo base_url('/property/browse/'. $propType->id); ?>"><?php echo $propType->name; ?></a><span>(<?php echo $propType->count; ?>)</span>
							</li>
				<?php endforeach ?>
			  </ul>
		  </div></div>
		  <div class="span4">
		    <div class="well-small">
		  <p class="category-title">Car and Vehicles</p>
			  <ul id="classifieds">
				<?php foreach($autoBrands as $brand): ?>
					    <li>
						<a href="<?php echo base_url('/automobiles/browse/'. $brand->brand_id); ?>"> <?php echo $brand->name; ?></a><span>(<?php echo $brand->count; ?>)</span>
						</li>
				<?php endforeach ?>
			  </ul>
		  </div>
		  </div>
		</div>
        <h3 class="title"><span class="pull-left">LATEST PROPERTY CLASSIFIEDS</span><span class="pull-right"><a href="<?php echo base_url('/property'); ?>">View all Property List</a></span></h3>
         <div class="row-fluid">
            <div class="row-fluid">
                <div calss="span12">
                     <div class="featured-item">
                      <?php if (isset($pspecial)) : ?>
                        <?php
                            if (isset($pspecial->primary_image)){
                                $url = '/assets/uploads/property/' .  $pspecial->primary_image;
                                }
                                else {
                                    $url = '/assets/uploads/dummy.png';
                                }
                        ?>
                        <a href="<?php echo base_url('/property') . '/details/'. $pspecial->propertyID; ?>">
                            <img src=<?php echo site_url($url); ?> alt="" title="" class="img pull-left" width="250px"
                            height="180px">
                        </a>
                        <strong><a href="<?php echo base_url('/property') . '/details/'. $pspecial->propertyID; ?>"><span class="propertyTitle"><?php echo  $pspecial->title; ?></span></a></strong>
                        <p class="propertyPublished">Posted: <?php echo date ("d/m/Y",strtotime($pspecial->posted_date)); ?>  <span>by</span> <a href="#" target="_blank"> <?php echo  $pspecial->firstName; ?></a> in <a href="<?php echo base_url('/property/browse') . '/'. $pspecial->id;?>"><?php echo  $pspecial->type; ?></a></p>
                        <?php 
                        $pspecial->description = (strlen($pspecial->description) > 600) ? substr($pspecial->description,0,600).'...' : $pspecial->description; ?>
                        <p><?php echo $pspecial->description; ?></p>
                    <?php endif; ?>
                    </div>
                 </div>
            </div>
            <ul class="thumbnails">  
                <?php foreach($plist as $property): ?>
            <li class="span6">  
                <div class="featured-item">
                    <a href="<?php echo base_url('/property') . '/details/'. $property->propertyID; ?>">
                        <img src="assets/img/products/8_photo_2993.jpg" alt="Investing in Stocks" title="Investing in Stocks" class="img pull-left">
                    </a>
                    <strong><a href="<?php echo base_url('/property') . '/details/'. $property->propertyID; ?>"><?php echo $property->title; ?></a></strong> in <a href="<?php echo base_url('/property') . '/browse/'. $property->id; ?>"> <?php echo $property->type; ?> </a>
                    <p>Posted: <?php echo date ("d/m/Y",strtotime($property->posted_date)); ?>
                    by <a href="#"> <?php echo $property->firstName; ?></a></p>
                    <p>
                         <?php 
                        $property->description = (strlen($property->description) > 180) ? substr($property->description,0,180).'...' : $property->description;
                        echo $property->description;
                         ?>
                    </p>
                    <p><span class="label label-info" style="padding: 5px 5px 5px 5px"><?php echo $property->price; ?></span> Lakhs</p>
                </div> 
            </li>
            <?php endforeach ?>  
         </ul>
            </div>
         </div>
        <h3 class="title"><span class="pull-left">RECENT ARTICLES</span><span class="pull-right"><a href="<?php echo base_url('articles');?>">View all articles</a></span></h3>
        <div class="row-fluid">
            <div class="span7">
            <?php foreach ($feature_articles as $farticle):  ?>
                 <?php
                    if (isset($farticle->image_url)){
                        $url = '/assets/uploads/articles/' .  $farticle->image_url;
                        }
                        else {
                            $url = '/assets/uploads/dummy.png';
                        }
                ?>
                <div class="featured-item">
                    <a href="<?php echo base_url('articles/entry/'. $farticle->url_title); ?>"><img src="<?php echo site_url($url); ?>" width="150" height="120" alt="<?php echo $farticle->title; ?>" title="<?php echo $farticle->title; ?>" class="img pull-left"></a>
                    <strong><a href="<?php echo base_url('articles/entry/'. $farticle->url_title); ?>"><?php echo $farticle->title; ?></a></strong>
                    <p>Published: <?php echo date ("d/m/Y",strtotime($farticle->creation_date)); ?> by <a href="#" target="_blank"> <?php echo $farticle->author; ?></a> in <a href="#"><?php echo $farticle->description; ?></a></p>
                    <p><?php echo $farticle->summary; ?></p>
                </div>
            <?php endforeach ?>
            </div>
            <div class="span5">
                <div class="other_info">
                    <?php foreach($articles as $article): ?>
                    <p>
                        <strong><a href="<?php echo base_url('articles/entry/'. $farticle->url_title); ?>"><?php echo $article->title; ?></a></strong>
                        <br/>in <?php echo $article->description; ?> <a href="#"></a> - <?php echo date("d/m/Y", strtotime($article->creation_date)); ?>				
                    </p>
                     <?php endforeach ?>  
                </div>
            </div>
        </div>
    </div>
</div>
<?php 
$this->load->view('includes/adv_rightnav.php');
$this->load->view('includes/footer.php');
?>
</div>	
<script src="<?php echo base_url("assets/js/jquery.ticker.js"); ?>"></script>	
<script>
$(document).ready(function(){
 $('#js-news').ticker();
});
</script>